﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Net.Mime.MediaTypeNames;

namespace Email
{
    public partial class email_detail : Form
    {
        private static string basepath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "data","emails"));
        public email_detail(int index,string user)
        {
            InitializeComponent();

            string filePath = Path.Combine(basepath, user,"test","raw_emails", $"raw_email{index}.txt");
            try
            {
                string content = File.ReadAllText(filePath);
                richTextBox4details.Text = content;
            }
            catch (FileNotFoundException)
            {
                MessageBox.Show($"File not found: {filePath}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"An error occurred while reading the file: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}
